/*
* Licensee agrees that the example code provided to Licensee has been developed and released by Bosch solely as an example to be used as a potential reference for application development by Licensee. 
* Fitness and suitability of the example code for any use within application developed by Licensee need to be verified by Licensee on its own authority by taking appropriate state of the art actions and measures (e.g. by means of quality assurance measures).
* Licensee shall be responsible for conducting the development of its applications as well as integration of parts of the example code into such applications, taking into account the state of the art of technology and any statutory regulations and provisions applicable for such applications. Compliance with the functional system requirements and testing there of (including validation of information/data security aspects and functional safety) and release shall be solely incumbent upon Licensee. 
* For the avoidance of doubt, Licensee shall be responsible and fully liable for the applications and any distribution of such applications into the market.
* 
* 
* Redistribution and use in source and binary forms, with or without 
* modification, are permitted provided that the following conditions are 
* met:
* 
*     (1) Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer. 
* 
*     (2) Redistributions in binary form must reproduce the above copyright
*     notice, this list of conditions and the following disclaimer in
*     the documentation and/or other materials provided with the
*     distribution.  
*     
*     (3)The name of the author may not be used to
*     endorse or promote products derived from this software without
*     specific prior written permission.
* 
*  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
*  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
*  DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
*  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
*  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
*  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
*  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
*  POSSIBILITY OF SUCH DAMAGE.
*/
/*----------------------------------------------------------------------------*/

/**
 * @brief Interface header for AppTxtParser.h
 *
 * @file
 */

/* header definition ******************************************************** */
#ifndef APPTXTPARSER_H_
#define APPTXTPARSER_H_

/* local interface declaration ********************************************** */
#include "BCDS_Retcode.h"

/**
 * @brief Structure for init credentials for AppTxtParser
 */
struct AppTxtParser_Init_S
{
    uint8_t * DataPointer;
    uint32_t DataLength;
    uint8_t DeviceMAC[6];
};

/**
 * @brief Typedef for init credentials for AppTxtParser
 */
typedef struct AppTxtParser_Init_S AppTxtParser_Init_T;

/**
* @brief Parse the config file read inside the buffer
*
* @param[in] initCredentials
* credentials for parsing
*
* @return true if configuration file is correct and contains necessary attribute/values
*/
Retcode_T AppTxtParser_Initialize(AppTxtParser_Init_T * initCredentials);

/**
 * @brief   Print list of configured values.
 *
 * @param[in] title
 *           title for list
 *
 * @param[in] defaultsOnly
 *           list only default values
 */
void AppTxtParser_PrintConfigurations(const char* title, bool defaultsOnly);

/**
 * @brief returns the attribute value for the token SSID as defined at the configuration file
 *
 * @note If attribute is not defined in configuration file it returns empty string
 */
const char *AppTxtParser_WLANSsidValue(void);

/**
 * @brief returns attribute value for the token PASSWORD as defined at the configuration file
 *
 * @note If attribute is not defined in configuration file it returns empty string
 */
const char *AppTxtParser_WLANPasswordValue(void);

/**
 * @brief returns attribute value for the token STATICIP as defined at the configuration file
 *
 * @note If attribute is not defined in configuration file it returns empty string
 */
bool AppTxtParser_WLANStaticIpValue(void);

/**
 * @brief returns attribute value for the token DNSSERVER as defined at the configuration file
 *
 * @note If attribute is not defined in configuration file it returns empty string
 */
uint32_t AppTxtParser_WLANIpAddrValue(void);
/**
 * @brief returns attribute value for the token DNSSERVER as defined at the configuration file
 *
 * @note  If attribute is not defined in configuration file it returns empty string
 */
uint32_t AppTxtParser_WLANDnsAddrValue(void);

/**
 * @brief returns attribute value for the token GATEWAY as defined at the configuration file
 *
 * @note If attribute is not defined in configuration file it returns empty string
 */
uint32_t AppTxtParser_WLANGwAddrValue(void);

/**
 * @brief returns attribute value for the token MASK as defined at the configuration file
 *
 * @note If attribute is not defined in configuration file it returns empty string
 */
uint32_t AppTxtParser_WLANMaskValue(void);

/**
 * @brief This function checks whether the lwm2m is secure or not based on the url.
 *
 * @return true if it is secure, false if not secure
 */
bool AppTxtParser_LWM2MIsSecureValue(void);
/**
 * @brief returns MAC address value for Lwm2m
 *
 */
const char *AppTxtParser_LWM2MMACAddrValue(void);

/**
 * @brief returns attribute value for the token LWM2MDERSRV as defined at the configuration file
 */
const char *AppTxtParser_LWM2MServerURLValue(void);

/**
 * @brief returns the port value extracted from the server url
 *
 */
uint32_t AppTxtParser_LWM2MServerPortValue(void);

/**
 * @brief returns attribute value for the token LWM2MENDPOINT as defined at the configuration file
 *
 * @note If attribute is not defined in configuration file it returns empty string
 */
const char *AppTxtParser_LWM2MEndPointValue(void);

/**
 * @brief returns the DTLS/PSK identity of the configuration file
 */
const char *AppTxtParser_DTLSPSKIdentityValue(void);

/**
 * @brief returns the DTLS/PSK secret key of the configuration file
 */
const char *AppTxtParser_DTLSPSKSecretKeyValue(void);

/**
 * @brief returns the DTLS/PSK secret key length of the configuration file
 */
uint32_t AppTxtParser_DTLSPSKSecretKeyLengthValue(void);

/**
 * @brief Returns the current configuration for the field TESTMODE set in the *.txt file
 *
 * @retval TESTMODE_OFF - If attribute token 'TESTMODE = NO',is defined in config file
 * @retval TESTMODE_ON  - If attribute token 'TESTMODE = YES', is defined in config file
 * @retval TESTMODE_MIX - If attribute token 'TESTMODE = MIX', is defined in config file
 *
 * @note  If no entry for TESTMODE configuration in SD card, then the default return value is TESTMODE_MIX
 */
uint8_t AppTxtParser_LWM2MTestModeValue(void);

/**
 * @brief returns lwm2m lifetime in seconds.
 */
uint32_t AppTxtParser_LWM2MLifetimeValue(void);

/**
 * @brief returns lwm2m binding value
 */
const char *AppTxtParser_LWM2MBindingValue(void);

/**
 * @brief returns the Lwm2m connection notify value
 */
bool AppTxtParser_LWM2MConNotifiesValue(void);


typedef int (*cbCfgProcKeyVal)(const char *key, char * val);

int parseCfgCotent(char * ramBufferRead, cbCfgProcKeyVal pfnxParseKeyVal );
#endif /* APPTXTPARSER_H_ */
